/*
ContactExtract
Version 1.0
Description: Controller class for GoogleContacts VisualForce page, class contaisn method for extracting contacts from Google account.
Author: Pratibh Prakash
Created Date: 27 Feb-2009
*/
public class ContactExtract {
	
	public string authToken { public get { 
        return ApexPages.currentPage().getParameters().get('sesstoken');
    } private set; }
    public string selectedSheet {get; set;}
    
    public List<SelectOption> getContacts(){
    	List<SelectOption> options = new List<SelectOption>();
    	if ( authToken == null ) return options;
    	
    	ContactService service = new ContactService();
    	service.setAuthSubToken(this.authToken);
    	
    	GoogleData  contactList = service.getContactsByTitle('a');
    	String idVal;
        String[] tokens;
        if(contactList != null){
            for(xmldom.element entry: contactList.entries){
                idVal = entry.getElementByTagName('id').nodeValue;
                tokens = idVal.split('/');
                idVal = tokens[tokens.size()-1];
                options.add(new SelectOption(idVal,
                                entry.getElementByTagName('title').nodeValue)
                            );
            }
        }
        return options;
    	
    }

}